package com.common.help.test18;

import java.util.Arrays;

public class Test {

	/*public static void main(String[] args) {
		
		*//**
		 * 2018-09-08 00:00:00     周六开始免费
		 * 2018-09-11 00:00:00     直到 周二 0点
		 * 2018-09-12 00:00:00     周三开始免费
		 * 2018-09-13 00:00:00     直到 周四 0点
		 *//*
		Long[] arr2={1536336000000L,1536595200000L,1536681600000L,1536768000000L};
		
		Long[] arr3 = new Long[arr2.length];
		
		//入场时间  2018-09-08 08:00:00
		long entryTime = 1536364800000L;
		//出场时间  2018-09-08 08:00:00
		long leaveTime = 1536742800000L;
		
		for(long l : arr2){
			
		}
		
	}*/
	
	public static long[] insert(long[] arr,long l){
		//新建数组,对原数组扩容
		long[] arr1 = new long[arr.length+1];
		//将原数组数据赋值给新数组
		for(int j = 0;j<arr.length;j++){
			arr1[j] = arr[j];
		}
		for(int j = 1;j<arr1.length+1;j++){
			long t = arr1[j-1];
			if(l<=t){
				arr1[j-1] = l;
				l = t;
			}else{
				if(t==0){
					arr1[j-1] = l;
				}
			}
		}
		return arr1;
	}
	public static int test(long[] a ,long b){
		for(int i=0;i<a.length;i++){
			if(a[i]==b){
				return i+1;
			}
		}
		return 0;
	}
	//测试
	public static void main(String[] args){
		long[] arr = {10,33,101,136,144,199,200,400,500};
		long[] arr1 = insert(arr,190);
		long[] arr2 = insert(arr1,450);
		
		long [] newData;
		int statr = test(arr2,190)-1;
		int end = test(arr2,450);
        newData = Arrays.copyOfRange(arr2,statr, end);
        for(long i:newData)
            System.out.print(i+" ");
    }

}
